package dto

import (
	"tuowei.com/app/admin/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type SysOfflineCourseGetPageReq struct {
	dto.Pagination `search:"-"`
	Name           string `form:"name" search:"type:contains;column:name;table:sys_offline_course" comment:"课程名称"` // 课程名称
	Status         int    `form:"status" search:"type:exact;column:status;table:sys_offline_course" comment:"状态"`  // 状态
	StartTime      string `search:"type:gte;column:created_at;table:sys_offline_course" form:"beginTime"`
	EndTime        string `search:"type:lte;column:created_at;table:sys_offline_course" form:"endTime"`
	Subject        string `search:"type:exact;column:subject;table:sys_offline_course" form:"subject" comment:"科目"`
	Province       string `form:"province" search:"type:contains;column:province;table:sys_offline_course" comment:"适用地区"`
	SysOfflineCourseOrder
}

type SysOfflineCourseOrder struct {
	CourseIdOrder  string `search:"type:order;column:course_id;table:sys_offline_course" form:"courseIdOrder"`
	CreatedAtOrder string `search:"type:order;column:created_at;table:sys_offline_course" form:"createdAtOrder"`
	UpdatedAtOrder string `search:"type:order;column:updated_at;table:sys_offline_course" form:"updatedAtOrder"`
}

func (m *SysOfflineCourseGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type OfflineStep1 struct {
	SerialNum      string  `json:"serial_num" comment:"课程编号"`                              // 课程编号
	Subject        string  `json:"subject" comment:"科目" vd:"@:len($)>0; msg:'请选择科目'"`      // 科目
	Name           string  `json:"name" comment:"课程名称" vd:"@:len($)>0; msg:'课程名称不能为空'"`    // 课程名称
	Cover          string  `json:"cover" comment:"封面" vd:"@:len($)>0; msg:'请上传课程封面'"`      // 封面
	Outline        string  `json:"outline" comment:"大纲" vd:"@:len($)>0; msg:'请上传课程大纲'"`    //大纲
	Price          float64 `json:"price" comment:"价格" vd:"$>0; msg:'请填写课程价格'"`             // 价格
	CourseDuration int     `json:"course_duration" comment:"课程时长" vd:"$>0; msg:'请输入课程时长'"` //课程时长
	Status         int     `json:"status" comment:"状态"`
	PublicRange    string  `json:"public_range" comment:"公开范围"`
	Province       string  `json:"province" comment:"适用地区" vd:"@:len($)>0; msg:'请选择适用区域'"` //适用区域
	LBTUrl         string  `json:"lbt_url" gorm:"type:varchar(5000);comment:轮播图地址"`
}

type OfflineStep2 struct {
	LecturerId int    `json:"lecturer_id" comment:"讲师"`
	ClassType  string `json:"class_type" comment:"班级类型" vd:"@:len($)>0; msg:'请选择班级类型'"` //初级、中级、高级
	//OnlineClassId  int     `json:"online_class_id" gorm:"type:tinyint(2);comment:网课班级ID"` //网课班级ID
	//OnlineClass    string  `json:"online_class" gorm:"type:varchar(20);comment:网课班级"`     //网课班级
	//Contacts       string  `json:"contacts" gorm:"type:varchar(50);comment:班主任联系"`        //班主任联系
	BelongingProvince int    `json:"belonging_province" comment:"所属大区"`
	City              int    `json:"city" gorm:"type:int(5);not null;comment:所属城市"`
	Area              int    `json:"area" gorm:"type:int(5);not null;comment:所属地区"`
	DeptId            int    `json:"dept_id" comment:"教学点"` //教学点
	Explain           string `json:"explain" comment:"食宿说明"`
	CourseDesExplain  string `json:"course_des_explain" comment:"课程详细说明" vd:"@:len($)>0; msg:'请填写课程详细说明'"`
	//BuyPush           int    `json:"buy_push" comment:"购买推送消息" vd:"$>0; msg:'请选择购买推送信息'"`
	BuyPush         int           `json:"buy_push" comment:"购买推送消息"`
	BindingOnlineId string        `json:"binding_online_id" comment:"绑定的网课ID"`
	TrainingDays    int           `json:"training_days" comment:"集训天数"`
	Telephone       string        `json:"telephone"`
	CourseGift      []*CourseGift `json:"course_gift" comment:"赠送数组"`
	ContactUrl      string        `json:"contact_url" comment:"合同地址"`
	FileId          string        `json:"file_id" comment:"e电签模板文件id"`
	Qq              string        `json:"qq" comment:"客服qq号"`
}

type SysOfflineCourseInsertReq struct {
	CourseId     int          `json:"course_id" comment:"课程ID"` // 课程ID
	OfflineStep1 OfflineStep1 `json:"offline_step1" comment:"步骤一"`
	OfflineStep2 OfflineStep2 `json:"offline_step2" comment:"步骤二"`
	common.ControlBy
}

func (s *SysOfflineCourseInsertReq) Generate(model *models.SysOfflineCourse) {
	//model.CourseId = s.CourseId
	model.Name = s.OfflineStep1.Name
	model.Status = s.OfflineStep1.Status
	model.Subject = s.OfflineStep1.Subject
	model.Cover = s.OfflineStep1.Cover
	model.ClassType = s.OfflineStep2.ClassType
	model.SerialNum = s.OfflineStep1.SerialNum
	model.Price = s.OfflineStep1.Price
	model.Outline = s.OfflineStep1.Outline
	model.Sales = 0
	model.CourseDuration = s.OfflineStep1.CourseDuration
	model.LecturerId = s.OfflineStep2.LecturerId
	model.Explain = s.OfflineStep2.Explain
	model.CourseDesExplain = s.OfflineStep2.CourseDesExplain
	model.Province = s.OfflineStep1.Province
	model.BelongingProvince = s.OfflineStep2.BelongingProvince
	model.BindingOnlineId = s.OfflineStep2.BindingOnlineId
	model.TrainingDays = s.OfflineStep2.TrainingDays
	model.City = s.OfflineStep2.City
	model.Area = s.OfflineStep2.Area
	model.DeptId = s.OfflineStep2.DeptId
	model.CreateBy = s.CreateBy
	model.Creator = s.Creator
	model.BuyPush = s.OfflineStep2.BuyPush
	model.Telephone = s.OfflineStep2.Telephone
	model.PublicRange = s.OfflineStep1.PublicRange
	model.LBTUrl = s.OfflineStep1.LBTUrl
	model.ContactUrl = s.OfflineStep2.ContactUrl
	model.FileId = s.OfflineStep2.FileId
	model.Qq = s.OfflineStep2.Qq
}

func (s *SysOfflineCourseInsertReq) GetId() interface{} {
	return s.CourseId
}

type SysOfflineCourseUpdateStatusReq struct {
	Status   int `json:"status" comment:"状态"`
	CourseId int `json:"course_id" comment:"课程ID" vd:"$>0; msg:'课程ID不能为空'"`
	common.ControlBy
}

func (s SysOfflineCourseUpdateStatusReq) Generate(model *models.SysOfflineCourse) {
	model.Status = s.Status
}

func (s SysOfflineCourseUpdateStatusReq) GetId() int {
	return s.CourseId
}

type SysOfflineCourseUpdateReq struct {
	CourseId     int          `json:"course_id" comment:"课程ID"` // 课程ID
	OfflineStep1 OfflineStep1 `json:"offline_step1"`
	OfflineStep2 OfflineStep2 `json:"offline_step2"`
	common.ControlBy
}

func (s *SysOfflineCourseUpdateReq) Generate(model *models.SysOfflineCourse) {
	if s.CourseId != 0 {
		model.CourseId = s.CourseId
	}
	model.Province = s.OfflineStep1.Province
	model.ClassType = s.OfflineStep2.ClassType
	model.SerialNum = s.OfflineStep1.SerialNum
	model.Subject = s.OfflineStep1.Subject
	model.Name = s.OfflineStep1.Name
	model.Cover = s.OfflineStep1.Cover
	model.Price = s.OfflineStep1.Price
	model.CreateBy = s.CreateBy
	model.CourseDuration = s.OfflineStep1.CourseDuration
	model.Outline = s.OfflineStep1.Outline
	model.CourseDesExplain = s.OfflineStep2.CourseDesExplain
	model.Explain = s.OfflineStep2.Explain
	model.BelongingProvince = s.OfflineStep2.BelongingProvince
	model.City = s.OfflineStep2.City
	model.Area = s.OfflineStep2.Area
	model.DeptId = s.OfflineStep2.DeptId
	model.LecturerId = s.OfflineStep2.LecturerId
	model.Status = s.OfflineStep1.Status
	model.BuyPush = s.OfflineStep2.BuyPush
	model.BindingOnlineId = s.OfflineStep2.BindingOnlineId
	model.TrainingDays = s.OfflineStep2.TrainingDays
	model.UpdateBy = s.UpdateBy
	model.Updater = s.Updater
	model.Telephone = s.OfflineStep2.Telephone
	model.PublicRange = s.OfflineStep1.PublicRange
	model.LBTUrl = s.OfflineStep1.LBTUrl
	model.ContactUrl = s.OfflineStep2.ContactUrl
	model.FileId = s.OfflineStep2.FileId
	model.Qq = s.OfflineStep2.Qq
}

func (s *SysOfflineCourseUpdateReq) GetId() interface{} {
	return s.CourseId
}

type UpdateOfflineCourseStatusReq struct {
	RoleId int    `json:"roleId" comment:"角色编码"` // 角色编码
	Status string `json:"status" comment:"状态"`   // 状态
	common.ControlBy
}

func (s *UpdateOfflineCourseStatusReq) Generate(model *models.SysRole) {
	if s.RoleId != 0 {
		model.RoleId = s.RoleId
	}
	model.Status = s.Status
}

func (s *UpdateOfflineCourseStatusReq) GetId() interface{} {
	return s.RoleId
}

type SysOfflineCourseByName struct {
	RoleName string `form:"role"` // 角色编码
}

type SysOfflineCourseGetReq struct {
	Id int `uri:"id"`
}

func (s *SysOfflineCourseGetReq) GetId() interface{} {
	return s.Id
}

type SysOfflineCourseDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *SysOfflineCourseDeleteReq) GetId() interface{} {
	return s.Ids
}

// RoleDataScopeReq 角色数据权限修改
type OfflineCourseDataScopeReq struct {
	RoleId    int    `json:"roleId" binding:"required"`
	DataScope string `json:"dataScope" binding:"required"`
	DeptIds   []int  `json:"deptIds"`
}

func (s *OfflineCourseDataScopeReq) Generate(model *models.SysRole) {
	if s.RoleId != 0 {
		model.RoleId = s.RoleId
	}
	model.DataScope = s.DataScope
	model.DeptIds = s.DeptIds
}

type SysOfflineCourseById struct {
	dto.ObjectById
	common.ControlBy
}

type BindESignTemplate struct {
	dto.Pagination `search:"-"`
	CourseId       int `form:"course_id"  json:"course_id" comment:"线下课程id" binding:"required"` // 线下课程id
	Id             int `form:"id" json:"id" binding:"required"`                                 // 模版id                            //
}

type GetCreateTemplateUrl struct {
	DocTemplateName string `json:"docTemplateName" binding:"required"`
	DocTemplateType int32  `json:"docTemplateType"`
	FileId          string `json:"fileId" binding:"required"`
	RedirectUrl     string `json:"redirectUrl"`
}

type GetTemplateDetail struct {
	DocTemplateId string `json:"docTemplateId" form:"docTemplateId"`
}
